﻿namespace Arms.Application
{
    using Arms.Domain;
    using Arms.Framework.Adapters;
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public static class ProjectionExtensions
    {
        /// <summary>
        /// Projects a type using a DTO.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static TResult As<TResult>(this object source) where TResult : EntityDTO, new()
        {
            return (TResult)TypeAdapterFactory.Adapter.Adapt<TResult>(source);
        }
        /// <summary>
        /// Projects an enumerable collection of items as DTO.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static List<TResult> AsCollection<TResult>(this object source) where TResult : EntityDTO, new()
        {
            return TypeAdapterFactory.Adapter.Adapt<List<TResult>>(source);
        }
        /// <summary>
        /// Projects an enumerable collection of items as ListItemDTO.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static List<TResult> AsListItemCollection<TSource, TResult>(this IEnumerable<TSource> source) where TSource : EntityDescribed where TResult : ListItemDTO, new()
        {
            throw new NotImplementedException();
        }
        /// <summary>
        /// Projects an Enum as a collection of key-value EnumDTO.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static List<TResult> AsEnumCollection<TResult>(this Enum source) where TResult : EnumDTO, new()
        {
            throw new NotImplementedException();
        }
    }
}
